package com.itheima.reggie.dao;

import com.itheima.reggie.entity.Dish;
import com.itheima.reggie.entity.DishDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;

public interface DishDao {
    @Select("select count(*) from dish where category_id=#{categoryId}")
    Integer findCountByCategoryId(Long categoryId);
    @Insert("insert into  dish values(null,#{name},#{categoryId},#{price},#{code},#{image},#{description},#{status},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser},0)")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id") //useGeneratedKeys = true 插入之后将主键自动封装到当前实体类对象。
    void save(DishDto dishDto);

    List<Dish> findAllByName(String name);
    @Select("select * from dish where id=#{id}")
    Dish findAllById(Long id);

    void update(DishDto dishDto);


    List<Dish> findDishById(Long categoryId,Integer status);


}
